/*
 * Copyright 2012 Jonathan St-Michel <jonathan@abiwebz.net>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.abiwebz.office.rm.database.configuration;

import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import net.abiwebz.office.rm.database.DatabaseDriver;

/**
 *
 * @author Jonathan St-Michel <jonathan@abiwebz.net>
 */
public abstract class DriverConfigurationPanel extends javax.swing.JPanel implements DocumentListener {

    public static final String PROP_JDBC_URL = "jdbc_url";
    
    protected DatabaseDriver driverInstance;
    protected String message;
    
    /**
     * Creates new form DriverConfigurationPanel
     */
    public DriverConfigurationPanel(DatabaseDriver driver) {
        this.driverInstance = driver;
        initComponents();
    }
    
    public String getMessage(){
        return message;
    }
    
    @Override
    public void insertUpdate(DocumentEvent e) {
        fire(e);
    }

    @Override
    public void removeUpdate(DocumentEvent e) {
        fire(e);
    }

    @Override
    public void changedUpdate(DocumentEvent e) {
        fire(e);
    }
    
    /**
     * Standard function used in insertUpdate, removeUpdate and 
     * changedUpdate. This way we only need to update one function.
     * 
     * @param e DocumentEvent called
     */
    public void fire(DocumentEvent e){
        firePropertyChange("DriverConfigurationPanel", 0, 1);
    }

    public abstract boolean check();
    public abstract String getJDBCUrl();
    
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 399, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 253, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
